package com.zhongkun.datahome.service.domain;

import java.math.BigDecimal;

import com.zhongkun.datahome.service.constant.MaterialTypeEnum;
import com.zhongkun.datahome.service.req.cmd.standard.DecorationStandardCmd;
import com.zhongkun.datahome.service.req.cmd.standard.DecorationStandardItemCmd;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * 装标明细对象 decoration_standard_item
 * 
 * @author ruoyi
 * @date 2025-04-14
 */
@Data
public class DecorationStandardItem extends BaseEntity {
    @ApiModelProperty("装标id")
    private Long standardId;

    /**
     * @see com.zhongkun.datahome.service.constant.MaterialTypeEnum
     */
    @ApiModelProperty("材料类型")
    private String materialType;

    @ApiModelProperty("材料id")
    private Long materialId;

    @ApiModelProperty("数量")
    private BigDecimal quantity;

    @ApiModelProperty("所属空间")
    private String room;

    @ApiModelProperty("渠道")
    private Integer channel;

    public static DecorationStandardItem of(DecorationStandardItemCmd cmd, Long standardId) {
        DecorationStandardItem item = new DecorationStandardItem();
        item.setMaterialType(MaterialTypeEnum.COMMON_SKU.getType());
        item.setStandardId(standardId);
        item.update(cmd);
        return item;
    }

    public void update(DecorationStandardItemCmd cmd) {
        // this.setMaterialType(cmd.getMaterialType());
        this.setMaterialId(cmd.getMaterialId());
        this.setQuantity(cmd.getQuantity());
        this.setRoom(cmd.getRoom());
        this.setChannel(cmd.getChannel());
    }
}
